package com.smart.village.big.screen.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.smart.village.big.screen.domain.*;
import com.smart.village.big.screen.mapper.AgricultureMapper;
import com.smart.village.big.screen.mapper.BenefitPeopleMapper;
import com.smart.village.big.screen.mapper.NewsMapper;
import com.smart.village.big.screen.service.AgricultureService;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class AgricultureServiceImpl implements AgricultureService {
    @Autowired
    private AgricultureMapper agricultureMapper;
    @Autowired
    private BenefitPeopleMapper benefitPeopleMapper;
    @Autowired
    private NewsMapper newsMapper;
    @Override
    public JSONObject getNaturalResourcesCoords(String townNumber, String villageNumber,String naturalResourceUsageSerialNumber,String naturalResourceTypeSerialNumber,String policyTypeSerialNumber,
                                                String cropCategorySerialNumber,
                                                String monitoringEquipmentSerialNumber) {

        JSONObject jsonObject = new JSONObject();

        if(StringUtils.isNotEmpty(policyTypeSerialNumber)){
            //补贴信息
            // 1 如果是 土地种植补贴 则 返回确权地块信息
            if("SPT000000000001".equals(policyTypeSerialNumber)){
                List<JSONObject> naturalResourcesPolicy = agricultureMapper.getNaturalResourcesPolicy(townNumber, villageNumber);
                jsonObject.put("type", "FeatureCollection");
                JSONObject crs = new JSONObject();
                crs.put("type", "name");
                JSONObject crsP = new JSONObject();
                crsP.put("name", "EPSG:4490");
                crs.put("properties", crsP);

                jsonObject.put("crs", crs);
                List<JSONObject> features = Lists.newArrayList();

                naturalResourcesPolicy.forEach(nature -> {

                    // 把这个类的具体信息 也返回
                    List<JSONObject> cropList =   agricultureMapper.getPolicyType1InfoByCategoryAndLandSerialNumber(policyTypeSerialNumber,nature.getString("naturalResourceSerialNumber"));
                    if(!CollectionUtils.isEmpty(cropList)){
                        nature.put("contentList",cropList);
                    }else{
                        nature.put("contentList", Lists.newArrayList());
                    }


                    JSONObject feature = new JSONObject();
                    feature.put("type", "Feature");
                    feature.put("id", nature.getString("naturalResourceSerialNumber"));
                    JSONObject geometry = new JSONObject();
                    geometry.put("type", "Polygon");
                    geometry.put("coordinates", nature.get("coords").toString().replace(" ", ""));
                    feature.put("geometry", geometry);
                    feature.put("properties", nature);
                    if (!ObjectUtils.isEmpty(nature.get("coords")) && !nature.get("coords").toString().replace(" ", "").equals("[]]")) {
                        nature.remove("coords");
                        features.add(feature);
                    }
                });
                jsonObject.put("features", features);
                return jsonObject;
            }
            // 2 如果是 农机购置补贴 则 返回当前申请人所在的蓝牌地点 point
            if("SPT000000000002".equals(policyTypeSerialNumber)){

                List<BluePlateInformation> agriculturalMachineryPolicy = agricultureMapper.getAgriculturalMachineryPolicy(townNumber, villageNumber);
                List<JSONObject> features = Lists.newArrayList();

                agriculturalMachineryPolicy.forEach(nature -> {

                    // 把这个类的具体信息 也返回
                    List<JSONObject> cropList =   agricultureMapper.getPolicyType2InfoByCategoryAndLandSerialNumber(policyTypeSerialNumber,nature.getBluePlateSerialNumber());
                    if(!CollectionUtils.isEmpty(cropList)){
                        nature.setContentList(cropList);
                    }else{
                        nature.setContentList(Lists.newArrayList());
                    }

                    JSONObject feature = new JSONObject();
                    feature.put("type", "Feature");
                    feature.put("id", nature.getBluePlateSerialNumber());
                    JSONObject geometry = new JSONObject();
                    geometry.put("type", "point");
                    geometry.put("coordinates", nature.getCoord().replace(" ", ""));
                    feature.put("geometry", geometry);
                    feature.put("properties", nature);
                    if (!ObjectUtils.isEmpty(nature.getCoord()) && !nature.getCoord().replace(" ", "").equals("[]]")) {
                        nature.setCoord("");
                        features.add(feature);
                    }
                });
                jsonObject.put("features", features);
                return jsonObject;
            }

            return jsonObject;
        }
        if(StringUtils.isNotEmpty(cropCategorySerialNumber)){
            // 3 作物信息
            // 返回今年所种植的 当前选择的作物类型的确权地块信息
            List<JSONObject> naturalResourcesPolicy = agricultureMapper.getCropCategoryCoords(cropCategorySerialNumber,townNumber, villageNumber);
            jsonObject.put("type", "FeatureCollection");
            JSONObject crs = new JSONObject();
            crs.put("type", "name");
            JSONObject crsP = new JSONObject();
            crsP.put("name", "EPSG:4490");
            crs.put("properties", crsP);

            jsonObject.put("crs", crs);
            List<JSONObject> features = Lists.newArrayList();

            naturalResourcesPolicy.forEach(nature -> {
                // 把这个类的具体信息 也返回
                List<JSONObject> cropList =   agricultureMapper.getCropInfoByCategoryAndLandSerialNumber(cropCategorySerialNumber,nature.getString("naturalResourceSerialNumber"));
                if(!CollectionUtils.isEmpty(cropList)){
                    nature.put("contentList",cropList);
                }else{
                    nature.put("contentList", Lists.newArrayList());
                }

                JSONObject feature = new JSONObject();
                feature.put("type", "Feature");
                feature.put("id", nature.getString("naturalResourceSerialNumber"));
                JSONObject geometry = new JSONObject();
                geometry.put("type", "Polygon");
                geometry.put("coordinates", nature.get("coords").toString().replace(" ", ""));
                feature.put("geometry", geometry);
                feature.put("properties", nature);
                if (!ObjectUtils.isEmpty(nature.get("coords")) && !nature.get("coords").toString().replace(" ", "").equals("[]]")) {
                    nature.remove("coords");
                    features.add(feature);
                }


            });
            jsonObject.put("features", features);
            return jsonObject;
        }
        if(StringUtils.isNotEmpty(monitoringEquipmentSerialNumber)){
            // 4 设备信息
            // 返回目前互联网设备 所在的标点
            List<JSONObject> features = Lists.newArrayList();
            List<JSONObject> deviceList = agricultureMapper.getDeviceCoords(monitoringEquipmentSerialNumber,townNumber, villageNumber);
                    deviceList.forEach(device -> {
                        JSONObject feature = new JSONObject();
                        feature.put("type", "Feature");
                        feature.put("id", device.getString("name"));
                        JSONObject geometry = new JSONObject();
                        geometry.put("type", "point");
                        geometry.put("coordinates", device.get("coords").toString().replace(" ", ""));
                        feature.put("geometry", geometry);
                        feature.put("properties", device);
                        if (!ObjectUtils.isEmpty(device.get("coords")) && !device.get("coords").toString().replace(" ", "").equals("[]]")) {
                            device.remove("coords");
                            features.add(feature);
                        }
            });
            jsonObject.put("features", features);
            return jsonObject;
        }


        if(StringUtils.isNotEmpty(naturalResourceUsageSerialNumber)) {
            List<JSONObject> naturalResourcesCoords = agricultureMapper.getNaturalResourcesCoords(townNumber, villageNumber, naturalResourceUsageSerialNumber, naturalResourceTypeSerialNumber);
            jsonObject.put("type", "FeatureCollection");
            JSONObject crs = new JSONObject();
            crs.put("type", "name");
            JSONObject crsP = new JSONObject();
            crsP.put("name", "EPSG:4490");
            crs.put("properties", crsP);

            jsonObject.put("crs", crs);

            List<JSONObject> features = Lists.newArrayList();

            naturalResourcesCoords.forEach(nature -> {
                JSONObject feature = new JSONObject();
                feature.put("type", "Feature");
                feature.put("id", nature.getString("naturalResourceSerialNumber"));
                JSONObject geometry = new JSONObject();
                geometry.put("type", "Polygon");
                geometry.put("coordinates", nature.get("coords").toString().replace(" ", ""));
                feature.put("geometry", geometry);
                feature.put("properties", nature);
                if (!ObjectUtils.isEmpty(nature.get("coords")) && !nature.get("coords").toString().replace(" ", "").equals("[]]")) {
                    nature.remove("coords");
                    features.add(feature);
                }

            });
            jsonObject.put("features", features);
            return jsonObject;
        }else{
            //5 默认返回以下 自然资源数据图斑
            List<JSONObject> naturalResourcesCoords = agricultureMapper.getNaturalResourcesBSMCoords(townNumber, villageNumber, naturalResourceUsageSerialNumber, naturalResourceTypeSerialNumber);
            jsonObject.put("type", "FeatureCollection");
            JSONObject crs = new JSONObject();
            crs.put("type", "name");
            JSONObject crsP = new JSONObject();
            crsP.put("name", "EPSG:4490");
            crs.put("properties", crsP);

            jsonObject.put("crs", crs);

            List<JSONObject> features = Lists.newArrayList();

            naturalResourcesCoords.forEach(nature -> {
                JSONObject feature = new JSONObject();
                feature.put("type", "Feature");
                feature.put("id", nature.getString("naturalResourceSerialNumber"));
                JSONObject geometry = new JSONObject();
                geometry.put("type", "Polygon");
                geometry.put("coordinates", nature.get("coords").toString().replace(" ", ""));
                feature.put("geometry", geometry);
                feature.put("properties", nature);
                if (!ObjectUtils.isEmpty(nature.get("coords")) && !nature.get("coords").toString().replace(" ", "").equals("[]]")) {
                    nature.remove("coords");
                    features.add(feature);
                }
            });
            jsonObject.put("features", features);
            // 乡镇边界
            JSONObject baseDistrictCoords = new JSONObject();
            baseDistrictCoords.put("type", "FeatureCollection");
            List<JSONObject> featuresDistrict = Lists.newArrayList();
            if(StringUtils.isNotEmpty(villageNumber)){
                String[] villageNumberSplit = villageNumber.split(",");
                for (String s : villageNumberSplit) {
                    String type = "1";
                    List<JSONObject>  baseDistrictCoordsList = agricultureMapper.getBaseDistrictCoordsList(s,type);
                    baseDistrictCoordsList.forEach(nature -> {
                        JSONObject feature = new JSONObject();
                        feature.put("type", "Feature");
                        JSONObject geometry = new JSONObject();
                        geometry.put("type", "Polygon");
                        geometry.put("coordinates", nature.get("Coords").toString().replace(" ", ""));
                        feature.put("geometry", geometry);
                        feature.put("properties", nature);
                        if (!ObjectUtils.isEmpty(nature.get("Coords")) && !nature.get("Coords").toString().replace(" ", "").equals("[]]")) {
                            nature.remove("Coords");
                            featuresDistrict.add(feature);
                        }
                    });
                }
            }else{
                String[] townNumberSplit = townNumber.split(",");
                for (String s : townNumberSplit) {
                    String type = "1";
                    List<JSONObject>  baseDistrictCoordsList = agricultureMapper.getBaseDistrictCoordsList(s,type);
                    baseDistrictCoordsList.forEach(nature -> {
                        JSONObject feature = new JSONObject();
                        feature.put("type", "Feature");
                        JSONObject geometry = new JSONObject();
                        geometry.put("type", "Polygon");
                        geometry.put("coordinates", nature.get("Coords").toString().replace(" ", ""));
                        feature.put("geometry", geometry);
                        feature.put("properties", nature);
                        if (!ObjectUtils.isEmpty(nature.get("Coords")) && !nature.get("Coords").toString().replace(" ", "").equals("[]]")) {
                            nature.remove("Coords");
                            featuresDistrict.add(feature);
                        }
                    });
                }
            }
            baseDistrictCoords.put("features", featuresDistrict);

            List<JSONObject> zhenfeaturesDistrict = Lists.newArrayList();
            String[] townNumberSplit = townNumber.split(",");
            for (String s : townNumberSplit) {
                String type = "0";
                List<JSONObject>  baseDistrictCoordsList = agricultureMapper.getBaseDistrictCoordsList(s,type);
                baseDistrictCoordsList.forEach(nature -> {
                    JSONObject feature = new JSONObject();
                    feature.put("type", "Feature");
                    JSONObject geometry = new JSONObject();
                    geometry.put("type", "Polygon");
                    geometry.put("coordinates", nature.get("Coords").toString().replace(" ", ""));
                    feature.put("geometry", geometry);
                    feature.put("properties", nature);
                    if (!ObjectUtils.isEmpty(nature.get("Coords")) && !nature.get("Coords").toString().replace(" ", "").equals("[]]")) {
                        nature.remove("Coords");
                        zhenfeaturesDistrict.add(feature);
                    }
                });
            }
            baseDistrictCoords.put("zhenDistrictCoords", zhenfeaturesDistrict);


            jsonObject.put("baseDistrictCoords", baseDistrictCoords);

            return jsonObject;
        }


    }

    @Override
    public List<JSONObject> getIndustrialStructureStatics(String year,String townNumber, String villageNumber) {
        return agricultureMapper.getIndustrialStructureStatics(year, townNumber,  villageNumber);
    }

    @Override
    public JSONObject getSubsidyInformation(String year, String townNumber, String villageNumber) {
        JSONObject jsonObject = new JSONObject();
        int policyCnt = agricultureMapper.getSubsidyInformationPolicyCnt(year);
        int policyArea = agricultureMapper.getSubsidyInformationPolicyArea(year, townNumber, villageNumber);
        int mainBodyCnt = agricultureMapper.getSubsidyInformationMainBodyCnt(year, townNumber, villageNumber);
        List<JSONObject> subsidyInformationBottomList = agricultureMapper.getSubsidyInformationBottomList(year, townNumber, villageNumber);
        jsonObject.put("policyCnt", policyCnt);
        jsonObject.put("policyArea", policyArea);
        jsonObject.put("mainBodyCnt", mainBodyCnt);
        jsonObject.put("list", subsidyInformationBottomList);
        return jsonObject;
    }

    @Override
    public JSONObject getPolicyAdvocacy(int pageNum, int pageSize,String NewsTerminal) {
        PageHelper.startPage(pageNum, pageSize);
        List<String> treeList = Lists.newArrayList();
        treeList.add("NC0000000000071");
        List<NewsVo> newsVos = newsMapper.selectNewsVoListInCategorySerialNumberList(treeList, "","",0,NewsTerminal);
        PageInfo<NewsVo> pageInfo = new PageInfo<>(newsVos);
        execFormatSubTitle(newsVos);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("news", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getProjectInformation(String year, String townNumber, String villageNumber) {
        JSONObject jsonObject = new JSONObject();
        List<JSONObject> target = agricultureMapper.getProjectInformationTarget(year,townNumber,villageNumber);
        jsonObject.put("target", target);
        List<JSONObject> list = agricultureMapper.getProjectInformationList(year,townNumber,villageNumber);
        jsonObject.put("list", list);
        return jsonObject;
    }

    @Override
    public JSONObject getNaturalResourcesConfirmationRights(String townNumber, String villageNumber) {
        List<JSONObject> naturalResourcesCoords = agricultureMapper.getNaturalResourcesConfirmationRights(townNumber, villageNumber);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("type", "FeatureCollection");
        JSONObject crs = new JSONObject();
        crs.put("type", "name");
        JSONObject crsP = new JSONObject();
        crsP.put("name", "EPSG:4490");
        crs.put("properties", crsP);

        jsonObject.put("crs", crs);

        List<JSONObject> features = Lists.newArrayList();

        naturalResourcesCoords.forEach(nature -> {
            JSONObject feature = new JSONObject();
            feature.put("type", "Feature");
            feature.put("id", nature.getString("naturalResourceSerialNumber"));
            JSONObject geometry = new JSONObject();
            geometry.put("type", "Polygon");
            geometry.put("coordinates", nature.get("coords").toString().replace(" ", ""));
            feature.put("geometry", geometry);
            feature.put("properties", nature);
            if (!ObjectUtils.isEmpty(nature.get("coords")) && !nature.get("coords").toString().replace(" ", "").equals("[]]")) {
                nature.remove("coords");
                features.add(feature);
            }
        });
        jsonObject.put("features", features);

        return jsonObject;
    }

    @Override
    public List<JSONObject> getSubsidyPolicyType() {
        return agricultureMapper.getSubsidyPolicyType();
    }

    @Override
    public List<JSONObject> getCropCategory() {
        return agricultureMapper.getCropCategory();
    }

    @Override
    public List<JSONObject> getMonitorDeviceCategory() {
        return agricultureMapper.getMonitorDeviceCategory();
    }

    @Override
    public List<JSONObject> getResourceUsageList() {
        return agricultureMapper.getResourceUsageList();
    }

    @Override
    public JSONObject getThreeResourceDisclosureInformation(String NewsTerminal, String townNumber, String villageNumber, int pageNum, int pageSize) {
        JSONObject jsonObject = new JSONObject();
        List<JSONObject> list = Lists.newArrayList();

        JSONObject categoryJson1 = new JSONObject();
        categoryJson1.put("categoryName", "资金公开");
        categoryJson1.put("categorySerialNumber", "NC0000000000070");
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> personalPointsAccountList1 = benefitPeopleMapper.getThreeResourceDisclosureList(NewsTerminal,townNumber, villageNumber,"NC0000000000070");
        PageInfo<JSONObject> pageInfo1 = new PageInfo<>(personalPointsAccountList1);
        categoryJson1.put("list", pageInfo1.getList());
        categoryJson1.put("categoryTotal", pageInfo1.getTotal());
        list.add(categoryJson1);


        JSONObject categoryJson2 = new JSONObject();
        categoryJson2.put("categoryName", "资产公开");
        categoryJson2.put("categorySerialNumber", "NC0000000000079");
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> personalPointsAccountList2 = benefitPeopleMapper.getThreeResourceDisclosureList(NewsTerminal,townNumber, villageNumber,"NC0000000000070");
        PageInfo<JSONObject> pageInfo2 = new PageInfo<>(personalPointsAccountList2);
        categoryJson2.put("list", pageInfo2.getList());
        categoryJson2.put("categoryTotal", pageInfo2.getTotal());
        list.add(categoryJson2);


        JSONObject categoryJson3 = new JSONObject();
        categoryJson3.put("categoryName", "资源公开");
        categoryJson3.put("categorySerialNumber", "NC0000000000080");
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> personalPointsAccountList3 = benefitPeopleMapper.getThreeResourceDisclosureList(NewsTerminal,townNumber, villageNumber,"NC0000000000070");
        PageInfo<JSONObject> pageInfo3 = new PageInfo<>(personalPointsAccountList3);
        categoryJson3.put("list", pageInfo3.getList());
        categoryJson3.put("categoryTotal", pageInfo3.getTotal());
        list.add(categoryJson3);

        jsonObject.put("list", list);
        jsonObject.put("zijingongkai", pageInfo1.getTotal());
        jsonObject.put("zichangongkai", pageInfo2.getTotal());
        jsonObject.put("ziyuangongkai", pageInfo3.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getMonitorDeviceList(String townNumber, String villageNumber, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> deviceList = agricultureMapper.getDeviceCoords("ME0000000000001",townNumber, villageNumber);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(deviceList);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }


    private void execFormatSubTitle(List<NewsVo> newsVoList) {
        newsVoList.forEach(newsVo -> {
            String newsSubTitle = newsVo.getNewsSubTitle();
            Document doc = Jsoup.parse(newsSubTitle);

            // 查找第一个<p>标签
            Elements paragraphs = doc.select("p");
            if (paragraphs.size() > 0) {
                Element firstParagraph = paragraphs.first(); // 获取第一个<p>标签
                String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                if (content.length() > 70) {
                    content = content.substring(0, 67) + "...";
                }
                newsVo.setNewsSubTitle(content);
                return;
            } else {
                Elements h1 = doc.select("h1");
                Elements h2 = doc.select("h2");
                Elements h3 = doc.select("h3");
                Elements h4 = doc.select("h4");
                Elements h5 = doc.select("h5");
                Elements ul = doc.select("ul");
                Elements ol = doc.select("ol");
                Elements li = doc.select("li");
                Elements div = doc.select("div");
                Elements span = doc.select("span");
                Elements strong = doc.select("strong");
                if (h1.size() > 0) {
                    Element firstParagraph = h1.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                }
                if (h2.size() > 0) {
                    Element firstParagraph = h2.first(); // 获取第一个<h2>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                }
                if (h3.size() > 0) {
                    Element firstParagraph = h3.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                }
                if (h4.size() > 0) {
                    Element firstParagraph = h4.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                }
                if (h5.size() > 0) {
                    Element firstParagraph = h5.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (ul.size() > 0) {
                    Element firstParagraph = ul.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (ol.size() > 0) {
                    Element firstParagraph = ol.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (div.size() > 0) {
                    Element firstParagraph = div.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (span.size() > 0) {
                    Element firstParagraph = span.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (strong.size() > 0) {
                    Element firstParagraph = strong.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } if (li.size() > 0) {
                    Element firstParagraph = li.first(); // 获取第一个<h1>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                }

            }
        });
    }
}
